2020 Method
Changes 0
M

AreaReinforcement.Create

Description:
Creates a new AreaReinforcement object from an array of curves. This method replaces the NewAreaReinforcement method, which has been deprecated.
Overloads (2):
Create(Document,Element,IList[Curve],XYZ,ElementId,ElementId,ElementId)
public static AreaReinforcement Create(
	Document document,
	Element hostElement,
	IList<Curve> curveArray,
	XYZ majorDirection,
	ElementId areaReinforcementTypeId,
	ElementId rebarBarTypeId,
	ElementId rebarHookTypeId
)
Return Value AreaReinforcement The newly created AreaReinforcement.
AreaReinforcement CreateAreaReinforcementInWall(Wall wall, Autodesk.Revit.DB.Document document)
{
    // Get the wall analytical profile whose curves will define the boundary of the the area reinforcement 
    AnalyticalModel analytical = wall.GetAnalyticalModel() as AnalyticalModel;
    if (null == analytical)
    {
        throw new Exception("Can't get AnalyticalModel from the selected wall");
    }

    IList<Curve> curves = analytical.GetCurves(AnalyticalCurveType.ActiveCurves);

    //define the Major Direction of AreaReinforcement,
    //we get direction of first Line on the Wall as the Major Direction
    Line firstLine = (Line)(curves[0]);
    XYZ majorDirection = new XYZ(
        firstLine.GetEndPoint(1).X - firstLine.GetEndPoint(0).X,
        firstLine.GetEndPoint(1).Y - firstLine.GetEndPoint(0).Y,
        firstLine.GetEndPoint(1).Z - firstLine.GetEndPoint(0).Z);

    // Obtain the default types
    ElementId defaultRebarBarTypeId = document.GetDefaultElementTypeId(ElementTypeGroup.RebarBarType);
    ElementId defaultAreaReinforcementTypeId = document.GetDefaultElementTypeId(ElementTypeGroup.AreaReinforcementType);
    ElementId defaultHookTypeId = ElementId.InvalidElementId;

    // Create the area reinforcement
    AreaReinforcement rein = AreaReinforcement.Create(document, wall, curves, majorDirection, defaultAreaReinforcementTypeId, defaultRebarBarTypeId, defaultHookTypeId);

    return rein;
}